//
//  KLDataStrongboxViewController.m
//  KISSLOCK
//
//  Created by 华杨科技 on 2017/4/21.
//  Copyright © 2017年 陈宾鹏. All rights reserved.
//  设置数据保险箱密码 

#import "KLDataStrongboxViewController.h"
#import "KLDataStrongboxView.h"
#import "KLHelp.h"
#import "HemaConst.h"
#import "JRToast.h"

@interface KLDataStrongboxViewController ()
@property (nonatomic, strong) KLDataStrongboxView *strongboxView; // 保险箱自定义view

@end

@implementation KLDataStrongboxViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self setNavAndSubviews];
}

// 设置导航条and布局子视图
- (void)setNavAndSubviews {
    self.view.backgroundColor = RGB_UI_COLOR(242, 242, 242);

    [KLHelp navSet:self doBackHandeler:^(UIButton *backButton) {
        [backButton addTarget:self action:@selector(doBack:) forControlEvents:(UIControlEventTouchUpInside)];
    }];
    
    
    
    // 自定义视图部分
    self.strongboxView = [[KLDataStrongboxView alloc] initWithFrame:CGRectMake(0, 64, UI_View_Width, 300)];
    [self.strongboxView pwdLabelString:@"保险箱密码" surepwdLabelString:@"确认密码"];
    [self.strongboxView clickButton:^(UIButton *sender) {
        [sender addTarget:self action:@selector(submitAction:) forControlEvents:(UIControlEventTouchUpInside)];
    }];
    [self.view addSubview:self.strongboxView];
    
}
- (void)doBack:(UIButton *)sender {
    [self.navigationController popViewControllerAnimated:YES];
}

// 点击按钮提交
- (void)submitAction:(UIButton *)sender {
    NSString *pwdStr = self.strongboxView.pwdTextfield.text;
    NSString *surepwdStr = self.strongboxView.surepwdTextfield.text;

    if ([KLHelp isSixdigitNumberString:pwdStr] && [KLHelp isSixdigitNumberString:surepwdStr]) {
        if ([pwdStr isEqualToString:surepwdStr]) {
        // 密码格式正确，进行设置数据保险箱密码操作
            NSLog(@"格式正确,继续下一步操作");
        }else {
            [JRToast showWithText:@"两次密码不一致请重新输入" duration:1.0];
        }
    }else {
       [JRToast showWithText:@"密码格式不正确请重新输入" duration:1.0];

    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
